package myBatis;

import java.io.IOException;
import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class SqlMapClient {
	private static SqlSession session;
	static {
		String resource = "myBatis/sqlMapConfig.xml";
		try {
			Reader reader = Resources.getResourceAsReader( resource );
			SqlSessionFactory sqlSession 
				= new SqlSessionFactoryBuilder().build( reader );
			session = sqlSession.openSession( true );			
		} catch (IOException e) {
			e.printStackTrace();
		}		
	}
	public static SqlSession getSqlSession() {
		return session;
	}
}




